project(SER_DES_TEST_NATIVE)

set(ARKTSCONFIG_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/arktsconfig_native.json")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/arktsconfig_native.json.in" "${ARKTSCONFIG_NATIVE_PATH}")

compile_panda_source_list(
    TARGET_NAME ser_des_test_native_srcs
    SOURCE_LIST
        "${SER_DES_TEST_SOURCE_DIR}/SerDesTest.ets"
    PREFIX_OUTPUT_FILE_NAME "Native"
    ARKTSCONFIG ${ARKTSCONFIG_NATIVE_PATH}
)

run_user_app(
    TARGET_NAME ser_des_test_native_run
    EXTRA_DEPS
        ser_des_test_native_srcs
        ser_des_user_native_srcs
        measure_native_lib_srcs
    CLASSNAME SerDesTest.SerDesTest
    USER_ABC_PATH ${CMAKE_CURRENT_BINARY_DIR}/SerDesTest_Native.abc
    NATIVE_PANDA_LIBRARY_PATH
        ${SER_DES_USER_NATIVE_BINARY_DIR}:${MEASURE_NATIVE_LIB_BINARY_DIR}
    EXTRA_BOOT_FILES
        ${SER_DES_USER_NATIVE_BINARY_DIR}/SerDesUserNative.abc
        ${MEASURE_NATIVE_LIB_BINARY_DIR}/MeasureNativeLib.abc
    EXTRA_LAUNCHER_OPTS
        ${ADDITIONAL_PANDA_ARGS_MERGED}

    ARK_AOT
    EXTRA_LAUNCHER_OPTS
        "--PandaOpt=--ext:--compiler-enable-jit=false"
        "--PandaOpt=--ext:--native-library-path=${SER_DES_USER_NATIVE_BINARY_DIR}:${MEASURE_NATIVE_LIB_BINARY_DIR}"
)
